//index.js
//获取应用实例
const app = getApp()
var serverUrl = app.globalData.serverUrl;
Page({
  data: {
    autoplay:true,
    circular:true,
    vertical:false,
    duration: 500,
    interval: 3000,
    vertical_notice:true,
    indicator_dots:true,
    toView: 'yellow',
    scrollLeft: 0,
    //滚动的数组
    scrolls: [],
    banner:[
      {
        name: 'reds',
      },
      {
        name: 'blacks',
      },
      {
        name: 'reds',
      },
      {
        name: 'blacks',
      },
      {
        name: 'reds',
      },
      {
        name: 'blacks',
      },
      {
        name: 'reds',
      },
      {
        name: 'blacks',
      },
    ],
    appre:[
      {
        name: 'ZNG',
        appre: "10000"
      },
      {
        name: 'ZNG',
        appre: "10000"
      },
      {
        name: 'ZNG',
        appre: "10000"
      },
      {
        name: 'ZNG',
        appre: "10000"
      },
      {
        name: 'ZNG',
        appre: "10000"
      },
      {
        name: 'ZNG',
        appre: "10000"
      },
      {
        name: 'ZNG',
        appre: "10000"
      },
      {
        name: 'ZNG',
        appre: "10000"
      }
    ],
    notices: [],
    noticeList:[]
  },
  
  onLoad: function () {
      var that = this;
      getNewLists(that);
      seachForPeopleNotice(that);
      notices(that);
  },

  /**列表跳转详情页**/
  navicatDetail:function(options){
    var id = options.currentTarget.id;
    wx.navigateTo({
      url: '../seek/detail/index?id='+id,
    })
  }

})

function getNewLists(that){
  wx.request({
    url: serverUrl + 'api/v1/seeks/newlists',
    method: "GET",
    dataType: "json",
    success: function (data) {
      data = data.data;
      if ( data.code == 200 ) {
        that.setData({
          scrolls:data.data
        })
      }
    },
    error: function (data) {

    }
  })
}

function seachForPeopleNotice(that){
  wx.request({
    url: serverUrl + 'api/v1/seeks/searchnotice',
    method: "GET",
    dataType: "json",
    success: function (data) {
      data = data.data;
      if (data.code == 200) {
        that.setData({
          notices: data.data
        })
      }
    },
    error: function (data) {

    }
  })
}

function notices(that){
  wx.request({
    url: serverUrl + 'api/v1/system/noticelist',
    method: "GET",
    dataType: "json",
    success: function (data) {
      data = data.data;
      if (data.code == 200) {
        that.setData({
          noticeList: data.data
        })
      }
    },
    error: function (data) {

    }
  })
}